<?php
/**
* Department data object
* @author trungdt
* @since Sep 1, 2011
* 
* Change logs
* Nov 1, 2011 - trungdt- Add module name to flexible include module
*/
class depmodule_dep {
	function form($object, $parent, $config) {
		if (!defined('SYS_FORMS')) require_once(BASE.'subsystems/forms.php');
		exponent_forms_initialize();

		$form = new form();
		if (!isset($object->id)) {
			$object->title = '';
			$object->content = '';
			$object->seo_name = '';
			$object->search_des = '';
			$object->parent_id=0;
			//
			$object->dont_show_info=0;
			$object->module_name="";
			
		} else {
			$form->meta('id',$object->id);
		}
		
		$form->meta('parent_id',$parent);
				
		$form->register('title','Node Title',new textcontrol($object->title));
		$form->register('seo_name','SEO name',new textcontrol($object->seo_name));
		$form->register("",null,new htmlcontrol("<p>Leave SEO field blank for automatic generate SEO name</p>"));
		$form->register('search_des','Search Description',new texteditorcontrol($object->search_des,3,80));
		$form->register('content','Node Content',new htmleditorcontrol($object->content));		
		$form->register("dont_show_info","Dont show the Node Content",new checkboxcontrol($object->dont_show_info,true));
		$form->register(null,"",new htmlcontrol("If you checked <b>Dont show the Node Content</b>, System will show only all the sub items in the Dep you selected"));
		
		$module_type=depmodule::__Module_Includeable();
		
		$form->register("module_name", "Module Type", new dropdowncontrol($object->module_name, $module_type));
		
		$form->register('submit','',new buttongroupcontrol('Save','','Cancel'));
		return $form;
	}

	function update($values,$object) {
		$object->title = $values['title'];
		$object->seo_name = $values['seo_name'];
		if (trim($object->seo_name) == "")
			$object->seo_name = _to_vietnamese_with_nomark($values['title']);
		$object->search_des = $values['search_des'];
		$object->parent_id = intval($values['parent_id']);
		$object->content = $values['content'];
		$object->module_name = $values['module_name'];
		if (isset($values['dont_show_info']))
		{
			$object->dont_show_info=1;
		}
		else
		{
			$object->dont_show_info=0;
		}
		return $object;
	}
}

?>